package gd.qaq.blue.powerparticle.commands;

import gd.qaq.blue.powerparticle.PowerParticle;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.*;

import static gd.qaq.blue.powerparticle.PowerParticle.colorFormat;


public class PowerParticleCommands implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender instanceof Player) {
            switch (args.length) {
                case 0:
                    help(sender);
                    return true;
                case 1:
                    switch (args[0]) {
                        case "reload":
                            PowerParticle.plugin.reload(sender);
                            return true;
                    }
            }
        }
        return false;
    }

    private void help(CommandSender player) {
        StringBuilder helpContent = new StringBuilder();
        if (player.isOp()) {
            helpContent.append("&6&l-----------&ePowerParticle&6&l------------\n");
            helpContent.append("&b(插件指令可以简化为pp)\n");
            helpContent.append("&b/powerparticle reload &e重载插件\n");
            helpContent.append("&6&l--------------------------------");
        }
        player.sendMessage(colorFormat(helpContent.toString()));
    }
}
